<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8" />
  <title>e</title>
  <!-- 引入Vue -->
  <script type="text/javascript" src="../../js/vue.js"></script>
</head>

<body>
  <!-- 准备好一个容器-->
  <div id="demo"></div>
</body>

<script type="text/javascript">
  // 创建组件
  let School = Vue.extend({
    name: 'School',
    data() {
      return {
        schoolName: '中央戏剧学院',
        schoolAddress: '北京'
      }
    },
    methods: {
      showSchool() {
        alert(`${this.schoolName},坐落于${this.schoolAddress}`)
      }
    },
    template: `
      <div>
        <h2>学校信息</h2>
        <h3>校名:{{schoolName}}</h3>
        <h3>地址:{{schoolAddress}}</h3>
        <input type='submit' @click='showSchool'/>
      </div>
    `
  });
  // 创建App组件
  let App = Vue.extend({
    components: { School },
    template: `
      <div>
        <School/>
      </div>
    `
  })

  // 创建Vue实例化
  new Vue({
    el: '#demo',
    components: { App },
    template: '<App/>'
  })
</script>

</html>